import { Controller, Get, Param, HttpCode, Query, UseGuards, Headers } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiResponse, ApiOperation, ApiBearerAuth, ApiTags, } from '@nestjs/swagger';
import { GetMovieDto, } from './dto/movie.dto';
import { MovieService } from './movies.service';
import { MovieEntity } from 'src/modules/admin/movies/entities/movie.entity';

@ApiBearerAuth() // swagger文档设置token
@ApiTags('电影')
@Controller('home/movie')
export class MovieController {
  constructor(private readonly movieService: MovieService) { }

  /** 获取电影列表 */
  @HttpCode(200)
  @Get('/getMoviePage')
  @ApiResponse({
    status: 200,
    description: '电影列表',
    type: MovieEntity,
    isArray: true,
  })
  @ApiOperation({
    tags: ['获取电影'],
    summary: '获取电影列表',
    operationId: 'getMoviePage',
  })
  async getMoviePage(@Query() params: GetMovieDto, @Headers('lang') lang: string) {
    return this.movieService.getMoviePage(params, lang);
  }
  /** 获取推荐剧集 */
  @HttpCode(200)
  @Get('/getRecommendations/:id')
  @ApiOperation({
    summary: '获取推荐剧集',
    operationId: 'getRecommendations',
  })
  async getRecommendations(@Param('id') movieId: number, @Headers('lang') lang: string) {
    return this.movieService.getRecommendations(movieId, lang);
  }
  /** 获取电影详情 */
  @HttpCode(200)
  @Get('/getMovieInfo/:id')
  @ApiOperation({
    summary: '获取推荐剧集',
    operationId: 'getMovieInfo',
  })
  async getMovieInfo(@Param('id') movieId: number, @Headers('lang') lang: string) {
    return this.movieService.getMovieInfo(movieId, lang);
  }

  /** 获取首页电影 */
  @HttpCode(200)
  @Get('/getHomeMovie')
  @ApiResponse({
    status: 200,
    description: '首页电影',
    type: MovieEntity,
    isArray: true,
  })
  @ApiOperation({
    tags: ['获取电影'],
    summary: '获取首页电影',
    operationId: 'getHomeMovie',
  })
  async getHomeMovie(@Headers('lang') lang: string) {
    return this.movieService.getHomeMovie(lang);
  }
}
